<%-- 
    Document   : game
    Created on : May 17, 2012, 2:55:22 PM
    Author     : Bhushan
--%>

<%@page import="src.DataAccess"%>
<%@page import="java.io.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import="src.Game"%>

<jsp:useBean id="game" class="src.Game" scope="application"/>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body onload="JavaScript:timedRefresh(5000);">

        <h1>Hello World!</h1>
        <form  name="computeForm" method="post" target="result" action="compute.jsp" >
            <hr>
            <input type="submit" name="command" value="Decrease Effort" ></input>
            <input type="submit" name="command" value="Increase Effort" ></input>
            <hr>
        </form>
        <form  name="releaseForm" method="post" target ="result2"action="release.jsp" >
            <hr>
            <input type="submit" name="command" value="Release" ></input>
            <hr>
        </form>


        <iframe iframe id="iframe" style="border: none;" name="result" width="300" height="700" src="compute.jsp">

    <frameset id="frameset1" cols="250,*"> 
        <frame  name="frame1" width="300" height="700" src="compute.jsp" />
    </frameset> 

    </iframe>

    <iframe iframe id="iframe2" style="border: none;" name="result2" width="300" height="300" src="release.jsp">
    </iframe>

    <script type="text/javascript">
        //document.computeForm.submit();
        function timedRefresh(timeoutPeriod) {
	
        <%
            String flag = "false";
            if (session.getAttribute("playerID") != null) {

                try {
                    int playerID = Integer.parseInt(session.getAttribute("playerID").toString());
                    boolean status = DataAccess.checkStatus(playerID);
                    if (!status) {
                        flag = "true";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        %>
                
                var reload=new Boolean(<%=flag%>);
                if(reload){
                    setTimeout("location.reload(true);",timeoutPeriod);
                    // document.getElementById("iframe").src = "compute.jsp";
                    document.computeForm.submit();
                }
            }
    </script>


</body>
</html>
